--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_clownpiece = General:new(extension, "hy_clownpiece", "chi_k", 3, 3, General.Female)
    local crazy_mind = fk.CreateSkill {
        name = "crazy_mind",
    }
    crazy_mind:addEffect(fk.EventPhaseStart, {
        anim_type = "control",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(crazy_mind.name) and target ~= player and target.phase == Player.Play and player:usedSkillTimes(crazy_mind.name, Player.HistoryRound) < 1 and not target.dead
        end,
        on_cost = function(self, event, target, player, data)
            return player.room:askToSkillInvoke(player, {
                skill_name = crazy_mind.name,
                prompt = "crazy_mind_prompt::" .. target.id
            })
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:drawCards(target, 3, crazy_mind.name)
            room:setPlayerMark(target, "@crazy_mind_counter-phase", "0")
        end,
    })
    crazy_mind:addEffect(fk.CardUseFinished, {
        can_refresh = function(self, event, target, player, data)
            return player:getMark("@crazy_mind_counter-phase") ~= 0 and player == target
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            local value = tonumber(player:getMark("@crazy_mind_counter-phase"))
            value = value + 1
            room:setPlayerMark(player, "@crazy_mind_counter-phase", tostring(value))
            if value == player.hp then
                room:loseHp(player, 1, crazy_mind.name)
                local discardCount = #player:getCardIds("h") - player.hp
                if discardCount > 0 then
                    room:askToDiscard(player, {
                        min_num = discardCount,
                        max_num = discardCount,
                        skill_name = crazy_mind.name,
                        cancelable = false
                    })
                end
            end
        end,
    })
    crazy_mind:addLoseEffect(function(self, player, is_death)
        local room = player.room
        for _, t in ipairs(room.alive_players) do
            room:setPlayerMark(t, "@crazy_mind_counter-phase", 0)
        end
    end)
    local star_stripes = fk.CreateSkill {
        name = "star_stripes",
    }
    star_stripes:addEffect(fk.Damaged, {
        anim_type = "control",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(star_stripes.name) and target == player
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            event:setCostData(self, table.map(room:askToChoosePlayers(player, {
                targets = room:getOtherPlayers(player),
                min_num = 1,
                max_num = 1,
                prompt = "star_stripes_prompt",
                skill_name = star_stripes.name
            }), Util.IdMapper))
            return #event:getCostData(self) > 0
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local skillTarget = room:getPlayerById(event:getCostData(self)[1])
            local success, useData = room:askToUseActiveSkill(skillTarget, {
                skill_name = "star_stripes_active",
                prompt = "star_stripes_active_prompt"
            })
            if not useData then
                if not skillTarget.dead then
                    room:drawCards(skillTarget, 2, star_stripes.name)
                    skillTarget:turnOver()
                end
            else
                room:throwCard(useData.cards, star_stripes.name, skillTarget, skillTarget)
            end
        end,
    })
    local star_stripes_active = fk.CreateSkill {
        name = "star_stripes_active",
    }
    star_stripes_active:addEffect("active", {
        target_num = 0,
        target_filter = Util.FalseFunc,
        card_filter = function(self, player, to_select, selected)
            if not table.contains(player:getCardIds("h"), to_select) then
                return false
            end
            return true
        end,
        feasible = function(self, player, selected, selected_cards, card)
            local num = 0
            for _, id in ipairs(selected_cards) do
                num = num + Fk:getCardById(id).number
            end
            return num >= 13
        end,
    })
    extension:loadSkillSkels { crazy_mind, star_stripes, star_stripes_active }
    hy_clownpiece:addSkill("crazy_mind")
    hy_clownpiece:addSkill("star_stripes")
    Fk:loadTranslationTable {
        ["hy_clownpiece"] = "克劳恩皮丝",
        ["#hy_clownpiece"] = "纯粹的生命",
        ["illustrator:hy_clownpiece"] = "ゆうじん",
        ["designer:hy_clownpiece"] = "黑曜人形",
        ["cv:hy_clownpiece"] = "",

        ["crazy_mind"] = "狂意",
        [":crazy_mind"] = "每轮限一次，其他角色的出牌阶段开始时，你可以令其摸三张牌。若如此做，其于本阶段使用第X张牌结算结束后失去1点体力，然后将手牌弃至体力值（X为其体力值）。",
        ["crazy_mind_prompt"] = "狂意：你可以令%dest摸三张牌，其有可能失去体力并弃牌",
        ["@crazy_mind_counter-phase"] = "狂意",

        ["star_stripes"] = "星条",
        [":star_stripes"] = "在你受到伤害后，你可以令一名其他角色选择一项：1.弃置任意张点数和不小于13的手牌；2.摸两张牌并翻面。",
        ["star_stripes_prompt"] = "星条：选择一名其他角色",
        
        ["star_stripes_active"] = "星条",
        ["star_stripes_active_prompt"] = "星条：弃置任意张点数和不小于13的手牌",
    }
end
